//从插件内导出createRouter、createWebHash
import { createRouter, createWebHashHistory } from "vue-router"; 

import LoginCom from "@/components/LoginCom.vue";
import RegisterCom from "@/components/RegisterCom.vue";
import HomeCom from "@/components/HomeCom.vue";
      import AddPerson from "@/components/home/AddPerson.vue";
      import ListPerson from "@/components/home/ListPerson.vue";
      import SchoolList from "@/components/home/SchoolList.vue";
      import EditPerson from "@/components/home/EditPerson.vue";
      import ProductList from "@/components/home/ProductList.vue";
      import EditProd from "@/components/home/EditProd.vue";
      
//定义路由表
const routes = [
    {
    path : '/',
    redirect :{
        name : 'LoginCom' //重定向
    }
    },
   //一个地址配置：/home的路径对应的组件是LoginCom
   {
    //：路由地址
    path : '/login',
    //命名路由：重定向、to属性
    name : 'LoginCom',
    //组件调用
    component : LoginCom,
},
{
    path : '/register',
    name : 'RegisterCom',
    component : RegisterCom,
},
{
    path : '/home',
    name : 'HomeCom',
    component : HomeCom,
    children : [
        {
            path : 'addperson',
            name : 'AddPerson',
            component : AddPerson
        },
        {
            path : 'listperson',
            name : 'ListPerson',
            component : ListPerson
        },
        {
            path : 'SchoolList',
            name : 'SchoolList',
            component : SchoolList
        },
        {
            path : 'editperson',
            name : 'EditPerson',
            component : EditPerson
        },
        {
            path : 'productlist',
            name : 'ProductList',
            component : ProductList
        },
        {
            path : 'editprod',
            name : 'EditProd',
            component : EditProd,
        }
    ]
},
];

//定义路由器/创建路由器
const router = createRouter({
    routes,

    //将路由历史模式设置为hash模式（哈希历史/模式）
    history : createWebHashHistory(),
});

//导出路由器
export default router;